package com.cxyzy.stopgif

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.gif.GifDrawable
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        Glide.with(this).asGif().load(R.drawable.test).into(imageView)
        button.setOnClickListener {
            if (imageView.drawable is GifDrawable) {
                val drawable = imageView.drawable as GifDrawable
                if (drawable.isRunning) {
                    drawable.stop()
                } else {
                    drawable.start()
                }
            }
        }

    }
}
